<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js"></script>
<script>

    // import CryptoJS from 'crypto-js';

    function encrypt(word,aesKey){
        var key = CryptoJS.enc.Utf8.parse(aesKey);
        var srcs = CryptoJS.enc.Utf8.parse(word);
        var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
        return encrypted.toString();
    }
    // 示例
    const data = "Supermapssdsdsds1997";
    const secretKey = "16af8cce8c944126"; // 密钥长度必须为16位
    const encryptedData = encrypt(data, secretKey);
    console.log(encryptedData);



    // var secretKey = "16af8cce8c944126"; // 与后端一致的密钥
    // var originalText = "Hello World!";
    // var cipher = CryptoJS.AES.encrypt(originalText, secretKey);
    // var encryptedText = cipher.toString();
    // console.log("Encrypted Text: " + encryptedText);
    // var decryptedText = CryptoJS.AES.decrypt(encryptedText, secretKey).toString(CryptoJS.enc.Utf8);
    // console.log("Decrypted Text: " + decryptedText);

</script>
</html>